﻿using B.S.DataBase.MyProject.Domain.ChronicDiseaseManagement;
using B.S.DataBase.MyProject.ErrorCode;
using MediatR;
using MedicalPCTerminal.Read.API.Appcation.Commands.ChronicCare;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace MedicalPCTerminal.Read.API.Controllers
{
    /// <summary>
    /// 慢病诊疗控制器-读
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ChronicCareController : ControllerBase
    {

        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator mediator;


        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="mediator"></param>
        public ChronicCareController(IMediator mediator)
        {

            this.mediator = mediator;
        }

        /// <summary>
        /// 慢病诊疗记录查询
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<MedicalRecord>>> GetChronicCareJL([FromQuery]QueryChronicCareJLCommand request, CancellationToken cancellationToken)
        {
            try
            {
                 return await mediator.Send(request, cancellationToken);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 慢病诊疗-复诊计划查询
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<FollowUpPlan>>> GetFollowUpPlan([FromQuery]QueryFollowUpPlanCommand request, CancellationToken cancellationToken)
        {
            try
            {
                 return await mediator.Send(request, cancellationToken);
            }
            catch (Exception)
            {

                throw;
            }
        }



    }

}
